<?php

/**
 * 
 *
 * @version $Id: news.inc.php,v 1.10 2005/08/01 10:16:40 phppc Exp $
 * @copyright 2004 
 **/

$colspan = 8;
$this->uf_field[1] = "n_title";
	$this->uf_input[1]["type"] = "text";
	$this->uf_input[1]["size"] = 60;
	$this->uf_input[1]["ml"] = 255;
	$this->uf_input[1]["colspan"] = 7;
$this->uf_field[2] = "bbcode";
	$this->uf_input[2]["type"] = "manually";
	$this->uf_input[2]["no_db"] = 1;
$this->uf_field[3] = "n_text";
	$this->uf_input[3]["type"] = "textarea";
	$this->uf_input[3]["cols"] = "60";
	$this->uf_input[3]["rows"] = "10";
	$this->uf_input[3]["add"] = " onChange=\"wohin(this)\" onclick=\"wohin(this)\" onFocus=\"wohin(this)\"";
	$this->uf_input[3]["colspan"] = 8;
$this->uf_field[4] = "kat";
	$this->uf_input[4]["type"] = "kat";
	$this->uf_input[4]["size"] = 4;
	$this->uf_input[4]["first_lang"] = "admin_news_4_first_select";
	$this->uf_input[4]["colspan"] = 8;
	$this->uf_input[4]["optional"] = 1;
$this->uf_field[5] = "links";
	$this->uf_input[5]["type"] = "textarea";
	$this->uf_input[5]["cols"] = 60;
	$this->uf_input[5]["rows"] = 4;
	$this->uf_input[5]["colspan"] = 8;
	$this->uf_input[5]["optional"] = 1;
$this->uf_field[6] = "time_start";
	$this->uf_input[6]["type"] = "manually";
$this->uf_field[7] = "time_end";
	$this->uf_input[7]["type"] = "manually";
$this->uf_field[8]	= "allow_coms";
	$this->uf_input[8]["type"] = "yes_no";
	$this->uf_input[8]["colspan"] = 8;


$news = $this->fun_sg2var("news");
$news_array = array();
if ($this->perm_array["news_write"] == 2 OR $this->perm_array["news_write"] == 1) {
	array_push($news_array,"new");
	$news_standard = "new";
}
if (($this->perm_array["news_edit_del"] == 2) OR $this->perm_array["news_edit_del"] == 1) array_push($news_array,"edit");
$news = $this->uf_form_conf_def($news,$news_array,$news_standard);

if ($news == "new") {
	$new = $this->fun_sg2var("new");
	$new = $this->uf_form_conf_def($new,array("form","insert"),"form");
       if ($new == "form") {
		// Newsstart
		$this->module_new_value["action"] = "news";
		$hidden_array["news"] = "new";
		$hidden_array["new"] = "insert";
		$this->tpl_load("news_bbcode","admin/");
		$this->tpl_replace_vars(array());
		$var_array['bbcode'] = $this->tpl_output();
		$src_time1 = $this->config["aktuelle_zeit"] + $this->time_add;
		$src_time2 = $this->config["aktuelle_zeit"] + $this->time_add;
		list($input_stunde,$input_minute,$input_tag,$input_monat,$input_jahr,$input_stunde_e,$input_minute_e,$input_tag_e,$input_monat_e,$input_jahr_e) = $this->news_time($src_time1,$src_time2);
		$this->tpl_load("news_nstart","admin/");
		$this->tpl_replace_vars(array("input_stunde" => $input_stunde,"input_minute" => $input_minute,"input_tag" => $input_tag,"input_monat" => $input_monat,"input_jahr" => $input_jahr));
		$var_array['time_start'] = $this->tpl_output();
		$this->tpl_load("news_nend","admin/");
		$this->tpl_replace_vars(array("input_stunde_e" => $input_stunde_e,"input_minute_e" => $input_minute_e,"input_tag_e" => $input_tag_e,"input_monat_e" => $input_monat_e,"input_jahr_e" => $input_jahr_e,"e_checked" => ""));
		$var_array['time_end'] = $this->tpl_output();
		$var_array["kat"] = 0;
		$nc_main = $this->uf_create_complete_form("admin_news_new_title",$hidden_array,"admin_news_new_submit","form_reset","complete_form","uf/","admin.php",$var_array,"admin_news_","text","icreator_one","uf/","","textarea",8,"<script language=\"JavaScript1.2\" src=\"../js/bbcode.js\"></script>","bbform");
		$help_id = 2;
	}elseif ($new == "insert") {
		$this->news_time2();
		list($input_array,$abfrage1,$abfrage2) = $this->uf_create_array_conf("insert");
		$valid_input = $this->uf_form_conf($input_array);
		if ($valid_input == 1) {
			if ($this->perm_array["news_write"] == 2) $action_active = 1;
			else $action_active = 0;
			$erg = $this->db_abfrage_q("INSERT ".$this->config["prefix"]."main ($abfrage1,user_id,active) VALUES ($abfrage2,\"".$this->user_id."\",\"$action_active\")");
			$news_id = $this->db_insert_id();
			if($erg) $this->message_green[] = 4;
		}else {
			$this->message_red[] = 1;
			$this->w_leitung["number"] = 1;
		}
	}
   }elseif($news == "edit") {
	$edit = $this->fun_sg2var("edit");
	$edit = $this->uf_form_conf_def($edit,array("form","do_edit"),"form");
	if ($edit == "form") {
		$db_news = $this->db_abfrage_az("SELECT * FROM ".$this->config["prefix"]."main WHERE news_id=\"".$_GET["news_id"]."\"");
		$db_news = $this->uf_secure($db_news);
	    $this->module_new_value["action"] = "news";
		$hidden_array["news"] = "edit";
		$hidden_array["edit"] = "do_edit";
		$hidden_array["news_id"] = $this->news_id;
		$this->tpl_load("news_bbcode","admin/");
		$this->tpl_replace_vars(array());
		$db_news['bbcode'] = $this->tpl_output();
		if ($db_news["time_end"] > 0) {
			$src_time2 = $db_news["time_end"] + $this->time_add;
			$e_checked = "checked ";
		}else {
			$src_time2 = $this->config["aktuelle_zeit"] + $this->time_add;
			$e_checked = "";
		}
		$src_time1 = $db_news["time_start"] + $this->time_add;
		list($input_stunde,$input_minute,$input_tag,$input_monat,$input_jahr,$input_stunde_e,$input_minute_e,$input_tag_e,$input_monat_e,$input_jahr_e) = $this->news_time($src_time1,$src_time2);
		$this->tpl_load("news_nstart","admin/");
		$this->tpl_replace_vars(array("input_stunde" => $input_stunde,"input_minute" => $input_minute,"input_tag" => $input_tag,"input_monat" => $input_monat,"input_jahr" => $input_jahr));
		$db_news['time_start'] = $this->tpl_output();
		$this->tpl_load("news_nend","admin/");
		$this->tpl_replace_vars(array("input_stunde_e" => $input_stunde_e,"input_minute_e" => $input_minute_e,"input_tag_e" => $input_tag_e,"input_monat_e" => $input_monat_e,"input_jahr_e" => $input_jahr_e, "e_checked" => $e_checked));
		$db_news['time_end'] = $this->tpl_output();
//		$db_news["kat"] = 0;
		$nc_main = $this->uf_create_complete_form("admin_news_edit_title",$hidden_array,"admin_news_edit_submit","form_reset","complete_form","uf/","admin.php",$db_news,"admin_news_","text","icreator_one","uf/","","textarea",8,"<script language=\"JavaScript1.2\" src=\"../js/bbcode.js\"></script>","bbform");
		$help_id = 2;
	}elseif ($edit == "do_edit") {
		$this->news_time2();
		list($input_array,$abfrage) = $this->uf_create_array_conf("update");
		$valid_input = $this->uf_form_conf($input_array);
		if ($valid_input == 1) {
			$erg = $this->db_abfrage_q("UPDATE ".$this->config["prefix"]."main SET $abfrage WHERE news_id=\"".$_POST["news_id"]."\"");
			if($erg) $this->message_green[] = 5;
		}else {
			$this->message_red[] = 1;
			$this->w_leitung["number"] = 1;
		}
	}
}

	
?>